#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

vector<double> medianSlidingWindow(vector<int>& nums, int k) {
    vector<double> ans;
    int n = nums.size();
    double window[n];
    int p = 0;
    for(int i=0;i<=n-k;i++){
        p = 0;
        for(int j=i;j<i+k;j++){
            window[p++] = nums[j];
        }
        sort(window, window + k);
        if(k % 2 == 1){
            ans.push_back(window[(k-1) / 2]);
        }else{
            ans.push_back(( window[(k-1) / 2] + window[(k+1) / 2] ) / 2);
        }
    }
    return ans;
}

int main() {
    cout << "hello world" << endl;
    vector<int> nums{1,4,2,3};

    vector<double> ans = medianSlidingWindow(nums, 4);
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << ", ";
    }
    return 0;
}